

using System.Linq;
using Abp;
using Abp.Authorization;
using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.MultiTenancy;
using WebApp.Authorization;

namespace WebApp.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="CompanyPermissions" /> for all permission names. Company
    ///</summary>
    public class CompanyAuthorizationProvider : AuthorizationProvider
    {
        private readonly bool _isMultiTenancyEnabled;

		public CompanyAuthorizationProvider()
		{

		}

       
        public CompanyAuthorizationProvider(bool isMultiTenancyEnabled)
        {
            _isMultiTenancyEnabled = isMultiTenancyEnabled;
        }

        public CompanyAuthorizationProvider(IMultiTenancyConfig multiTenancyConfig)
        {
            _isMultiTenancyEnabled = multiTenancyConfig.IsEnabled;
        }

		public override void SetPermissions(IPermissionDefinitionContext context)
		{
			// 在这里配置了Company 的权限。



			//// custom codes
			context.CreatePermission(CompanyPermissions.Node, L(CompanyPermissions.Node));
			context.CreatePermission(CompanyPermissions.Query, L(CompanyPermissions.Query));
			context.CreatePermission(CompanyPermissions.Create, L(CompanyPermissions.Create));
			context.CreatePermission(CompanyPermissions.Edit, L(CompanyPermissions.Edit));
			context.CreatePermission(CompanyPermissions.Delete, L(CompanyPermissions.Delete));
			context.CreatePermission(CompanyPermissions.BatchDelete, L(CompanyPermissions.BatchDelete));
			context.CreatePermission(CompanyPermissions.ExportExcel, L(CompanyPermissions.ExportExcel));


			//// custom codes end
		}

		private static ILocalizableString L(string name)
		{
			return new LocalizableString(name, AbpConsts.LocalizationSourceName);
		}
    }
}
